package com.flexdms.i18n;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

import org.apache.deltaspike.core.api.provider.BeanProvider;

public class FacesLocaleDetector implements PhaseListener
{

	
	@Override
	public void afterPhase(PhaseEvent event)
	{
		
		LocaleHolder localeHolder=BeanProvider.getContextualReference(LocaleHolder.class, false);
		localeHolder.setCurrentLocale(event.getFacesContext().getViewRoot().getLocale());
	}

	@Override
	public void beforePhase(PhaseEvent event)
	{
		
		
	}

	@Override
	public PhaseId getPhaseId()
	{
		return PhaseId.RESTORE_VIEW;
	}

}
